package com.example.xd.mvp_project.view.activity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import com.example.xd.mvp_project.R;
import com.example.xd.mvp_project.base.BaseActivity;
import com.example.xd.mvp_project.comment.Constans;
import com.example.xd.mvp_project.utils.SpUtils;

public class SplashActivity extends BaseActivity implements SplashView {


    private ImageView mSpalshImg;
    private boolean mIsFirst;

    @Override
    protected void doBussiness() {
        Log.i("xd---", "splash");
        mIsFirst = SpUtils.getBoolean(this, Constans.Is_First, false);
        Animation animation = AnimationUtils.loadAnimation(this, R.anim.splash_anim);
        mSpalshImg.setAnimation(animation);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                mSpalshImg.setVisibility(View.GONE);
                if (mIsFirst) {
                    startActivity(LoginActivity.class);
                    finish();
                } else {
                    startActivity(MainActivity.class);
                    finish();
                }
                overridePendingTransition(R.anim.activity_enter, R.anim.activity_exit);

            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });


    }


    @Override
    public View bindView() {
        return null;
    }

    @Override
    public void initParams(Bundle bundel) {

    }

    @Override
    protected int bindLayout() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initView(View contextView) {
        mSpalshImg = contextView.findViewById(R.id.spalsh_img);
    }


    @Override
    protected void setListener() {

    }

    @Override
    protected void widgetClick(View v) {

    }

}
